import 'package:flutter/material.dart';
import 'package:maihealth/class/home/model/ziXunModel.dart';
import 'package:maihealth/utils/constant.dart';
import 'package:maihealth/utils/httpUtils.dart';
import 'package:maihealth/class/home/model/homeModel.dart';
import 'package:provide/provide.dart';

class homeProvide with ChangeNotifier{
  //资讯列表模型数据
List<ziXunModel> listDatas = [];
  //请求首页数据
  Future requestHomeData() async{
     var response = await HttpUtils.get('/api/home/index/');
      homeModel model = homeModel.fromJson(response['data']);
      return model;
  }

    //请求首页数据
 Future requestZiXunListData(int page) async{
     var response = await HttpUtils.get('/api/news/list/',params: {'cid':"0",'Limit':ROW,'page':page});
     print('resp===${response}');
     if(page==1){
       listDatas.clear();
     }
      List items  =  response['data'];
      for (var item in items) {
        ziXunModel model  = ziXunModel.fromJson(item);
        listDatas.add(model);
      }
      return items.length;
  }
}